// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

//include_path: ../../helper_components

import { StyleMetrics } from "std-widgets.slint";
import { ExportedGlobal as ReexportedGlobal } from "export_globals.slint";

struct MyStruct := { x:int, y: int, }

global InternalGlobal := {
    property <int> hello: 42;
    property <MyStruct> my_struct;
    pure callback sum(int, int)->int;
}

export { InternalGlobal as PublicGlobal }
export { ReexportedGlobal }

TestCase := Rectangle {
    property <bool> test_global_prop_value: InternalGlobal.hello == 100;
    property <int> test_call_callback: InternalGlobal.sum(6, 4);
}

/*
```rust
let instance = TestCase::new().unwrap();
assert!(!instance.get_test_global_prop_value());
assert_eq!(PublicGlobal::get(&instance).get_hello(), 42);
instance.global::<PublicGlobal>().set_hello(100);
assert!(instance.get_test_global_prop_value());

assert_eq!(ReexportedGlobal::get(&instance).get_foo(), 44);

instance.global::<PublicGlobal>().on_sum(|a, b| a + b);
assert_eq!(instance.get_test_call_callback(), 10);
assert_eq!(instance.global::<PublicGlobal>().invoke_sum(4, 5), 9);
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(!instance.get_test_global_prop_value());
assert_eq(instance.global<PublicGlobal>().get_hello(), 42);
instance.global<PublicGlobal>().set_hello(100);
assert(instance.get_test_global_prop_value());

assert_eq(instance.global<ReexportedGlobal>().get_foo(), 44);

instance.global<PublicGlobal>().on_sum([](int a, int b) { return a + b; });
assert_eq(instance.get_test_call_callback(), 10);
assert_eq(instance.global<PublicGlobal>().invoke_sum(4, 5), 9);
```

```js
let instance = new slint.TestCase({});
assert(!instance.test_global_prop_value);
// TODO
```

*/
